home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / CM / TESTPORT.ZIP / TESTPORT.DOC < prev   
Encoding:
Text File  |  1993-12-08  |  24.5 KB  |  508 lines

  1.    Slicware is Copy(c)right 1989,1992 by Gary M. Raymond, New Orleans, La.
  2.            Port Modem Register Test Program V1.1 by Gary M. Raymond
  3.                               HOME of SlicWare
  4.  
  5.                               Gary M. Raymond
  6.                                 P.O.Box 8184
  7.                            New Orleans, La.  70182
  8.                                (504) 288-6550
  9.                             Compuserve 70613,3165
  10.  
  11.  
  12.  
  13.    Files Provided:
  14.    ====================================================================
  15.  
  16.    TESTPORT.COM   Serial Port Test Utility.
  17.    TESTPORT.DOC   This document.
  18.  
  19.    TestPort will run on just about any version of DOS and with any
  20.    amount of RAM. If nothing else, TestPort will assist you in learning
  21.    more about serial communications and understanding your modem. Having
  22.    written and supported several terminal programs over the past seven
  23.    years, I have long ago realized that most problems involving terminal
  24.    software are actually modem or modem configuration problems. This
  25.    utility should take some of the mystery away from configuring,
  26.    understanding, and diagnosing serial communications hardware. If for
  27.    no other reason than curiosity, you owe it to your modem to use
  28.    TestPort at least once and read through this file. TestPort was
  29.    written in ASIC, and, I will gladly supply the source code with your
  30.    registration, if requested.
  31.  
  32.    ====================================================================
  33.    TestPort is a basic, easy to use, modem diagnostic tool. Although the
  34.    information TestPort provides will at first be seemingly cryptic to
  35.    the novice user, it can easily be learned and put to good use.  Bit
  36.    mapping the modem registers provides a wealth of information about
  37.    the state of your modem. Your modem is both configured and monitored
  38.    through these registers or electronic switches. Everything from baud
  39.    rate to data parity is determined by the one (on) or zero (off) bit
  40.    settings in these registers. Particular register bits are also used
  41.    to inform the terminal program that a character has arrived or is
  42.    ready to be transmitted along with numerous other useful information.
  43.  
  44.    According to the IBM scheme of things, you could have as many as
  45.    65,536 port addresses. These ports have an address in the hardware
  46.    set up according to IBM's scheme. Each address points to a one byte
  47.    location called a base address. Since we can both set and retrieve
  48.    bits in these bytes we refer to them as maskable base registers. Each
  49.    of the next subsequent nine bytes (BASE+1, BASE+2 etc) form that
  50.    ports general register set as outlined in the text below. Serial
  51.    communication ports begin with COM Port number one (COM1) with an
  52.    address assigned by IBM as decimal 1016 or 3F8 hex. Hence, the
  53.    address for the COM1 port register is 3F8. This is the place where a
  54.    byte of data is received (3F8 - Received Data Register) or sent (3F8
  55.    - Transmitter Holding Register) depending on requirements at the
  56.    moment. Therefore the base address allows indirect access to both the
  57.    THR and RDR (plus BRDL when bit 7 of LCR is set). The next register
  58.    (the IER) is located at this base address plus one, (3F8 + 1 = 3F9)
  59.    and so on.
  60.  
  61.    There are two general methods of obtaining bytes of data from a
  62.    serial port after it has been set up. The first involves stoping
  63.    every so often and looking to see if a byte has arrived, and if so,
  64.    taking it. This method of polling the modem registers is ok when
  65.    working at very slow baud rates. Polling is the method used by the
  66.    PC's Basic Input Output Service (BIOS firmware.) Unfortunately, if a
  67.    byte of data arrives before we have had a change to remove the
  68.    previous one, information can be lost. To overcome this drawback of
  69.    polling we can force the PC to react to the arrival of a byte by
  70.    removing and saving it in a special storage area until we have time
  71.    to use it. This is done by designing a special Interrupt Service
  72.    Routine (ISR) that will be activated instantly (no matter what else
  73.    the PC may be doing) to collect and store the byte of data. This is
  74.    referred to as an "interrupt on receive" terminal program, such as
  75.    our product, SLICK terminal.
  76.  
  77.    There are many things that can go wrong when installing a modem
  78.    on your computer. Usually, problems are evenly divided between
  79.    hardware and software configuration errors. In general, the modem
  80.    itself must be mechanically set, via jumper pins or dip switches,
  81.    to address whatever available serial port is usable on your PC.
  82.    The selected port must also be paired with an interrupt request line
  83.    (IRQ). Note, no two serial devices (examp: modem and mouse) may share
  84.    actively the same serial port IRQ address. Some modems force, or
  85.    allow you to force, certain register bits either high (1) or low (0)
  86.    in lieu of preferred software control. TestPort is useful in
  87.    EXAMINING all of the register settings that occur as a results of
  88.    these various configurations. Improper configuration of software is
  89.    another problem. Here, there are generally three areas of trouble.
  90.    Improper comm port, interrupt and modem command (initialization)
  91.    string settings. So, to review, One: the serial services must first
  92.    be available on the PC. Two: both the modem and terminal software
  93.    must agree in settings with the PC hardware you are attempting to
  94.    access. And finally, the modem initialization command string must
  95.    correctly complete the job of setting any other registers that
  96.    require attention, such as setting FAX mode on or off, hardware error
  97.    correction enabled or disabled, etc. etc. For what its worth, just
  98.    one wrong AT command in the string will cause the entire string to
  99.    FAIL. So, if your particular brand modem does not use &D1 (set dtr)
  100.    as an example, and, it is inserted into your complete string, such as
  101.    ATM1S0=0V1X4&D1S7=45, then the entire string will fail returning an
  102.    error message, leaving your modem still waiting to be configured.
  103.  
  104.    ====================================================================
  105.    USING TestPort's register mapping ability:
  106.  
  107.    To run TestPort with mapping action, you must pass the active port
  108.    number via a command parameter. TestPort will work on the four
  109.    standard IBM default ports of 1 (3F8), 2 (2F8), 3 (3E8), and 4 (2E8).
  110.    Let's assume your modem is configured to operate using COM2. Type
  111.    TESTPORT 2 at the DOS prompt. In most cases, you will really want to
  112.    do this while your terminal program is active. You do this by
  113.    dropping to DOS from within your terminal program, then executing
  114.    TestPort. Most all Terminal programs have a drop to DOS feature,
  115.    although it might be called something else. TestPort does a passive
  116.    read only on these registers and therefore will in no way alter or
  117.    change their bit settings. By using the drop to dos feature, which
  118.    allows the modem code to remain loaded in ram, you eliminate the
  119.    possibility that any modem registers will be inadvertently altered,
  120.    by your terminal program, before you get to read the registers. Some
  121.    terminal programs also have features that allow the naming and
  122.    execution of any external dos utility via a combination of trigger
  123.    hot keys. This is a MUCH better way of quickly running TestPort.
  124.    Don't forget in either case to pass the active port number in use.
  125.    (i.e. TESTPORT 2.)  If TestPort is executed as an external utility,
  126.    screen output data will remain until a key is pressed. This will give
  127.    you opportunity to hit Shft PrtSc and save a copy of the screen to
  128.    your printer for evaluation and analysis. If you do not have a
  129.    printer, you should make a long hand record on paper.
  130.  
  131.    USING TestPort's UART finder:
  132.  
  133.    Running TestPort without a port parameter will cause TestPort to
  134.    cycle through the four common UART addresses looking for an active
  135.    (U)niversal (A)synchronous (C)ommunications (C)ontroller. (8250 IC)
  136.    If active port addresses are located, TestPort will notify you of
  137.    those that appeared active. Notice, I said appeared active. It is
  138.    possible to have two serial ports but only one terminated to a
  139.    modem. The other may be just a jack on the rear of your PC, there
  140.    for some later expansion. A simple serial card with its open jack
  141.    will still show as an active port.
  142.  
  143.    Screen Output:
  144.    ------------------------------------------------------------------------
  145.    The Correct Syntax is TESTPORT #, (# to test), i.e. TESTPORT 4,
  146.    however, TestPort will now try to determine what if any serial
  147.    port is responding to TestPort's Inquiries....................
  148.  
  149.    COM1 appears to have an active UART!
  150.    COM2 appears to be inactive.
  151.    COM3 appears to be inactive.
  152.    COM4 appears to have an active UART!
  153.  
  154.    Enter Port# to test or Esc to exit ->
  155.  
  156.    In five seconds type AT <Enter>, active port will echo OK or 0, else Esc!
  157.    ------------------------------------------------------------------------
  158.  
  159.    Although this kind of information is by far un-conclusive, it does
  160.    give you enough insights to continue experimenting. In the case of
  161.    the information given above, the modem must be attached to either
  162.    COM1 or COM4. To determine which it is, try entering 1 first. If
  163.    there is no echoing of your keystroke or an OK reply to AT (the modem
  164.    attention command) the probability is COM1 is not the port connected
  165.    to your modem. Now try 4. This should test ok! More than likely, COM1
  166.    is an extra, as of yet unused, serial adapter.
  167.  
  168.    Although this testing facility is only a raw polling terminal, set to
  169.    1200 baud, N81, it can easily be used for simple task, like dialing
  170.    out to test other modems etc. Try typing ATH1 and see if you hear
  171.    your modem take the line off hook....ATH0 to replace it. Fun hun?
  172.  
  173.    ====================================================================
  174.    SCREEN GENERATED BY TESTPORT when mapping registers:
  175.  
  176.    When TestPort is run, it produces the following screen, indicating
  177.    the various one byte registers that have been read, their decimal,
  178.    hex, and (binary) bit map values. It's those bit settings you are
  179.    most interested in. The two indirect registers (THR and RDR) read
  180.    via the base register are not useful here. However, those two plus
  181.    the eight indicated account for the 10 registers of a UART chip.
  182.  
  183.          *******************************************************
  184.              Modem Register Bit Map by Gary M. Raymond SSC
  185.                         Phone (504) 288-6550
  186.  
  187.          Modem Registers     Dec Value    Hex Value     Bit Map
  188.                                                         76543210
  189.          IER (Int Enable)             0           00    00000000
  190.          IIR (Int ID)                 1           01    00000001
  191.          LCR (Line Control)           3           03    00000011
  192.          MCR (Modem Cont)             8           08    00001000
  193.          LSR (Line Status)           97           61    01100001
  194.          MSR (Modem Status)          48           30    00110000
  195.          BRDL (Low Register)          6           06    00000110
  196.          BRDH (Hi  Register)          0           00    00000000
  197.          *******************************************************
  198.  
  199.  
  200.          Hit Any Key to Exit!
  201.  
  202.  
  203.  
  204.    NOTE: Bit positions are read left to right, starting with position
  205.          0 (zero) and ending with 7. This accounts for a full byte of
  206.          eight bits.
  207.  
  208.    ====================================================================
  209.    SAMPLE USES for TESTPORT:
  210.  
  211.    Q) My modem wont hang up, what do I look for?
  212.    A) Look at bits 0 and 1 of MCR after starting your terminal program
  213.       but before dialing a number. They should both be set to 1. If not
  214.       check to see if your modem requires external dip switch settings
  215.       to force DTR, RTS or software AT commands like &D2 and &C1.
  216.  
  217.    Q) How can I tell if my terminal program is interrupt driven or
  218.       a polling BIOS type?
  219.    A) Look at bit 0 of IER, it will be set to 1 if the terminal is
  220.       interrupt driven. Also, bit 3 of MCR is usually set to 1 as
  221.       well. These bits are set to 0 (zero) in a polling terminal.
  222.  
  223.    Q) My modem wont respond on COM2.
  224.    A) Run TESTPORT 2. If If you see each modem register returning FF hex
  225.       (dec 255 or 11111111 binary) odds are this port is not activated
  226.       correctly via pin or dip settings on the modem card. Check your
  227.       modem manual for correct pin or dip switch settings.
  228.  
  229.    Q) How can I tell what Baud rate my modem is locked at?
  230.    A) First, run TestPort and obtain the BRDL and BRDH register values.
  231.       Then cross reference them with the Baud Rate Value chart in this
  232.       document file.
  233.  
  234.    Q) Can I use TestPort to place a call to a BBS?
  235.    A) Yes, but it's VERY limited as a polling terminal and not intended
  236.       for that kind of application. No protocols, no dial directory, no
  237.       no nothing, just a bare foot terminal!
  238.  
  239.    Q) My modem and software configured for COM3 is brain dead, can
  240.       TestPort help?
  241.    A) You bet! Some serial communications software, especially tsr type,
  242.       use BIOS services for communicating with the serial ports. BIOS
  243.       then depends on DOS to insert the correct port addresses into the
  244.       BIOS area of memory. Some versions of DOS fail to place the
  245.       default addresses for COM3 and COM4 in the required BIOS area of
  246.       memory. TestPort overcomes this limitation by poking ALL of the
  247.       IBM default addresses (3F8 - 2F8 - 3E8 - 2E8) into the correct
  248.       area of bios memory starting at segment 0040. This feature is
  249.       automatic anytime you run TestPort in any mode. To cancel out
  250.       these values, you only need reboot the PC. I will also provide a
  251.       seperate utility (PCA.COM) that can be used via your autoexec.bat
  252.       to insure these addresses are always available after bootup.
  253.  
  254.    Q) My terminal program has a host mode that allows remote access to
  255.       DOS via a redirection statement in a batch file. Only guess what?
  256.       It locks up my computer. Can TestPort help me?
  257.    A) Well, maybe. There are many computers (clones or otherwise) that
  258.       just do not take kindly to re-direction. (CTTY COM1 or CTTY > AUX1
  259.       type calls) If the reason is due to the problem outlined in the
  260.       answer above, TestPort or PCA will solve it. If not, there is
  261.       a device driver in the public domain called GateWay that usually
  262.       will accept re-direction. It can be found on most BBS'es. One
  263.       nice thing about GateWay is it still allows access to the host
  264.       keyboard and monitor; simple re-direction does not.
  265.  
  266.    Q) Can I use TestPort to see the default and or active settings
  267.       of all registers in my modem?
  268.    A) Yes, actually, you can do that with any terminal program. To use
  269.       TestPort, type TESTPORT at the dos prompt. Select the active port
  270.       number and wait five seconds for the terminal to respond. Type
  271.       AT&V then hit enter. On some older modems you cannot dump the
  272.       entire register set and you must poll each individually. Say
  273.       you want to see the present value in S7, type ATS7? and so on.
  274.  
  275.    Q) My old modem had a volume control on the card. My new one does
  276.       not. Can TestPort save my marriage and turn down the volume?
  277.    A) Yes, and again, it can also be done with your present terminal.
  278.       By default most modems allow the speaker on at full volume. You
  279.       can control this by resetting the M and L registers. ATM1 will
  280.       turn off the sound after a connect and ATL0 will reduce the volume
  281.       to the lowest setting. Of cource, these switches belong together
  282.       in your initialization command string. (ATM1L1etc.etc.etc.)
  283.  
  284.    ====================================================================
  285.    MODEM REGISTER BIT MAP DATA:
  286.  
  287.        For general purpose information, the port addresses of
  288.        these registers are as follows:
  289.  
  290.        BASE = COMPORT ADDRESS  (COM1 = 3F8h)
  291.        Therefore, MCR for COM1 equals 3F8h + 4 or 3FCh
  292.  
  293.        Ten Modem Registers
  294.        ---------------------------------------------
  295.        THR,RDR, *BRDL =  BASE
  296.        IER,     *BRDH =  BASE  + 1  ;  Interrupt Enable Register
  297.        IIR            =  BASE  + 2  ;  Interrupt Identification Register
  298.        LCR            =  BASE  + 3  ;  Line Control Register
  299.        MCR            =  BASE  + 4  ;  Modem Control Register
  300.        LSR            =  BASE  + 5  ;  Line Status Register
  301.        MSR            =  BASE  + 6  ;  Modem Satus Register
  302.        ---------------------------------------------
  303.                 *requires bit 7 set to 1 in LCR for access
  304.    ====================================================================
  305.  
  306.        IER  BIT MAPPING   (Interrupt Enable Register)
  307.        ---------------------------------------------
  308.        BIT     Activates             Action
  309.        0    =  Data Received         Read RDR
  310.        1    =  THR empty             Output to THR
  311.        2    =  Data error/break      Read LSR
  312.        3    =  MSR change            Read MSR
  313.        4    =  zero
  314.        5    =  zero
  315.        6    =  zero
  316.        7    =  zero
  317.  
  318.        Although the 8250 Uart has 10 one byte registers, only seven have
  319.        direct access, and of the seven, three of these are used
  320.        redundantly to gain access to the three non directly accessible
  321.        registers. This indirect access is achieved by setting bit 7 of
  322.        LSR to 1. Then, the BRDL and BRDH registers are accesses at BASE
  323.        and BASE + 1. These two registers are used to lock the port baud
  324.        rate. The BRD (Baud Rate Divisor) is a 16 bit number (two bytes)
  325.        and therefore requires two (one byte) register access through
  326.        BASE and BASE + 1. Interesting enough, the high byte is only
  327.        necessary for baud rates of 300 or below. At 1200 or higher BRDH
  328.        is set at zero. The formula for calculating the BRD value
  329.        demonstrates why.
  330.  
  331.                       UART CLOCK SPEED (1.8432mhz)
  332.               BRD =   ----------------------------
  333.                       16 x bit transfer rate (not really baud)
  334.  
  335.                       1,843,200
  336.               BRD =   ---------   =   256 or    110000000  or 100h
  337.                       16 x 300
  338.                                                 B   B
  339.                                                 R   R
  340.                                                 D   D
  341.                       breaking the result into  H   L
  342.                       two bytes produces =      1 & 1000000
  343.  
  344.                       where BRDH = 1hex and BRDL = 80h (128 dec)
  345.  
  346.               FOR 1200 BAUD:
  347.  
  348.                       1,843,200
  349.               BRD =   ---------   =   96 or    1100000  or 60h
  350.                       16 x 1200
  351.                                                 B   B
  352.                                                 R   R
  353.                                                 D   D
  354.                       breaking the result into  H   L
  355.                       two bytes produces =      0 & 1100000
  356.  
  357.                       where BRDH = 0hex and BRDL = 60h (96 dec)
  358.  
  359.  
  360.        The THR (Transmit Holding Register) and RDR (Received Data Register)
  361.        are accessed via the same physical address as the port base address.
  362.        Since you cannot in theory send and receive at the same instant, this
  363.        little scheme seems ok.
  364.  
  365.  
  366.  
  367.        IIR  BIT MAPPING   (Interrupt Identification Register)
  368.        ---------------------------------------------
  369.        BIT
  370.        0    =  more than 1 intr has occurred
  371.  
  372.                12                       12
  373.        1-2  =  00  change in MSR        10    data received
  374.                01  THR empty            11    recv error/break
  375.  
  376.        3    =  zero
  377.        4    =  zero
  378.        5    =  zero
  379.        6    =  zero
  380.        7    =  zero
  381.  
  382.  
  383.        LCR  BIT MAPPING   (Line Control Register)
  384.        ---------------------------------------------
  385.        BIT                      01                 01
  386.        01   =  Data Length      00=5bits           10=7bits
  387.                                 01=6bits           11=8bits
  388.  
  389.        2    =  Stop Bits        0=1bit             1=2bits
  390.  
  391.                                 345                345
  392.        345  =  Parity           000=NONE           101=MARK
  393.                                 100=ODD            111=SPACE
  394.                                 110=EVEN
  395.  
  396.        6    =  Break Condition  0=disabled         1=enabled
  397.        7    =  Port Toggle      0=Use THR/RDR/IER  1=Use BRDL/BRDH
  398.  
  399.  
  400.        SAMPLE: Using N parity, 8 data bits and 1 stop bit requires
  401.        the LCR register of 00000000 to be then set as follows:
  402.                            76543210 = bit pattern
  403.                                  11 = 8 bits
  404.                                 0   = 1 stop bit
  405.                              000    = no parity
  406.                             0       = break disabled
  407.                            0        = toggle inactive
  408.                          ----------
  409.                            00000011 = 3h to send to LCR
  410.  
  411.  
  412.        Bit 7 of LCR controls the dual function of bits 0 and 1 in the
  413.        IER Register and should be set to zero in the above example.
  414.  
  415.  
  416.  
  417.        MCR  BIT MAPPING   (Modem Control Register)
  418.        ---------------------------------------------
  419.        BIT
  420.        0    =  Set DTR line active
  421.        1    =  Set RTS line active
  422.        2    =  USER BIT #1
  423.        3    =  USER BIT #2
  424.        4    =  UART loopback
  425.        5    =  zero
  426.        6    =  zero
  427.        7    =  zero
  428.  
  429.        Bit 3 is normally set to 1 for interrupt driven terminal
  430.        programs. Most programs force the modem to hang up by setting
  431.        bits 0 and 1 to 0. Modem software setup for these first two bits
  432.        therefore is usually 1 and 1.
  433.  
  434.  
  435.        LSR  BIT MAPPING   (Line Status Register)
  436.        ---------------------------------------------
  437.        BIT
  438.        0    =  byte in RDR (received)
  439.        1    =  overrun in RDR
  440.        2    =  Parity error detected
  441.        3    =  Framing error (out of sync, no stop bit received)
  442.        4    =  Break Detect
  443.        5    =  THR empty
  444.        6    =  TSR empty (removes char from THR)
  445.        7    =  Time Out
  446.  
  447.  
  448.        A communications program usually checks bit 5 here before sending
  449.        another character out the base port.
  450.  
  451.  
  452.        MSR  BIT MAPPING   (Modem Status Register)
  453.        ---------------------------------------------
  454.        BIT
  455.        0    =  change in [C]lear [T]o [S]end  CTS
  456.        1    =  change in [D]ata [S]et [R]eady DSR
  457.        2    =  change in ring indicator RI
  458.        3    =  change in [D]ata [C]arrier [D]etect  DCD
  459.        4    =  Clear to send ..... [CTS] set high
  460.        5    =  Data set ready .... [DSR] set high
  461.        6    =  Ring Indicator .... [RI]  set high
  462.        7    =  Data Carrier detect [DCD] set high
  463.  
  464.        Most BBS programs monitor bit 7 of the MSR to determine
  465.        if carrier is lost during a logon.
  466.  
  467.    ===================================================================
  468.        BAUD RATE DIVISOR (BRD Register) CHART
  469.  
  470.        Bit Rate            BRDH           BRDL
  471.        ---------------------------------------
  472.        50                   09h            00h
  473.        110                  04h            17h
  474.        300                  01h            80h
  475.        ---------------------------------------
  476.        1200                 00h            60h   From 1200 up, BRDH is
  477.        2400                 00h            30h   always set to zero!
  478.        4800                 00h            18h
  479.        9600                 00h            0Ch
  480.        19200                00h            06h
  481.  
  482.    ===================================================================
  483.  
  484.    Registering your copy will help continue the competitive advantages
  485.    of providing economical shareware. As an additional bonus, I will
  486.    ship you several other useful modem and dos utilities free!  If
  487.    you have any comments or suggestions about this utility, feel free
  488.    to write or call.
  489.  
  490.    Name_____________________________________________________________
  491.  
  492.    Mailing Address__________________________________________________
  493.  
  494.    City & State ___________________________________________________
  495.  
  496.    ZIP _____________________________ Phone _________________________
  497.  
  498.    Send $4 + $1 (ship & hand) check or money order to:
  499.  
  500.                               Gary M. Raymond
  501.                                 P.O.Box 8184
  502.                             New Orleans, La. 70182
  503.                                 504-288-6550
  504.                             Compuserve 70613,3165
  505.    ====================================================================
  506.                                      EOF
  507.  
  508.